#ifndef video2_H
#define video2_H

#include <QObject>
#include <QThread>
#include <QImage>
#include <opencv/cv.h>
#include <QMutex>
#include <stdio.h>
#include <stdlib.h>
#include <opencv/highgui.h>
#include <opencv/cxcore.h>
#include<QMessageBox>

static QImage IplImage2QImage( IplImage *iplImage)
{
 int height = iplImage->height;
 int width = iplImage->width;
// const uchar *qImageBuffer =;
QImage img((const uchar*)iplImage->imageData, width, height, QImage::Format_RGB888);
return  img.rgbSwapped();
}

class video2:public QThread
{
Q_OBJECT
public:
int time;
void load_cam();
video2();
~video2();
void set_inertie(int);
bool isrunning;
bool ISRUNNING;
int my_option;


bool a_norm;
bool a_nb;
bool a_eq;
bool a_hist;
int a_cumul;
int max_hist;

long bins_nb[256];
long bins_r[256];
long bins_g[256];
long bins_b[256];

public slots:
void run();
void end();
private:
void set_flow(IplImage *);
long compute_hist_8U (const IplImage* , long* , int );
QMutex mutex;
CvCapture *avi;
IplImage *im;
IplImage *imprc;

QList<double> *listx;
QList<double> *listy;
int nb_point;
signals:
void video2_updated(QImage,double,double );
};

#endif // video2_H
